/**
 * MFProcessDraft.cpp
 *
 * Copyright (c) 2007 Autodesk, Inc. All Rights Reserved.
 *
 * Owner: Felix Gu
 * Creation Date: 08/01/2008
 */
#include "StdAfx.h"
#include "ProcessDraft.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

CProcessDraft::CProcessDraft()
: m_pBlockMap(NULL)
{
	m_pBlockMap = new BlockMap();
}

CProcessDraft::~CProcessDraft()
{
	for (BlockMap::iterator it = m_pBlockMap->begin();
		it != m_pBlockMap->end(); it ++)
	{
		delete it->second;
		it->second = NULL;
	}
	m_pBlockMap->clear();

	delete m_pBlockMap;
	m_pBlockMap = NULL;
}

IObjectBlock* CProcessDraft::GetBlock(CString strInterName)
{
	BlockMap::iterator it = m_pBlockMap->find(strInterName);
	if (it == m_pBlockMap->end())
	{
		return NULL;
	}

	return it->second;
}

HRESULT CProcessDraft::AddBlock(CString strInterName, IObjectBlock* pBlock)
{
	BlockMap::iterator it = m_pBlockMap->find(strInterName);
	if (it == m_pBlockMap->end())
	{
		m_pBlockMap->insert(BlockPair(strInterName, pBlock));
		return S_OK;
	}
	else
	{
		return E_FAIL;
	}
}